package 反射;

/*
    静态代理:代理类和被代理类在编译期间就确定下来了
 */
public class StaticProxy08 {

    public static void main(String[] args) {
        //被代理类对象
        NikeClothFactory nike = new NikeClothFactory();

        //代理类对象
        ProxyClothFactory proxyClothFactory = new ProxyClothFactory(nike);

        //方法调用
        proxyClothFactory.produceCloth();
    }

}

//接口
interface ClothFactory{

    void produceCloth();

}

//代理类
class ProxyClothFactory implements ClothFactory{

    private ClothFactory factory; //使用被代理类对象进行实例化

    public ProxyClothFactory(ClothFactory factory){
        this.factory = factory;
    }

    @Override
    public void produceCloth() {
        System.out.println("代理工厂的准备工作...");
        this.factory.produceCloth();
        System.out.println("代理工厂的收尾工作...");
    }
}

//被代理类
class NikeClothFactory implements ClothFactory{

    @Override
    public void produceCloth() {
        System.out.println("Nike工厂生产一批运动服");
    }

}


